#ifndef MAPPING_MAP_LOADER_H
#define MAPPING_MAP_LOADER_H

#include <string>
#include <yaml-cpp/yaml.h>
#include <fstream>
#include <glog/logging.h>
#include <ros/ros.h>


struct Map_info{
    Map_info(){}
    Map_info(unsigned int map_width_,unsigned int map_height_,double res_,std::string frame_id_,
             double map_ori_x_,double map_ori_y_,double map_ori_z_){
        res        = res_;
        map_height = map_height_;
        map_width  = map_width_;
        frame_id   = frame_id_;
        map_ori_x  = map_ori_x_;
        map_ori_y  = map_ori_y_;
        map_ori_z  = map_ori_z_;
    }
    double res;
    unsigned int map_width;
    unsigned int map_height;
    std::string frame_id;
    double map_ori_x,map_ori_y,map_ori_z;
};
class Map_loader{
public:
    Map_loader(std::string map_yaml_path_,std::string map_data_path_);
    void get_map_info(Map_info& map_info_in){
        map_info_in.frame_id = map_info.frame_id;
        map_info_in.res  =  map_info.res;
        map_info_in.map_height = map_info.map_height;
        map_info_in.map_width  = map_info.map_width;
        map_info_in.map_ori_x = map_info.map_ori_x;
        map_info_in.map_ori_y = map_info.map_ori_y;
        map_info_in.map_ori_z = map_info.map_ori_z;
    }
    void get_map_data(unsigned char** map_data_){
        *map_data_ = map_data;
    }
private:
    //void DEBUG_pub_2d_map();
    void load_map_data();
    void load_map_yaml();
private:
    std::string map_yaml_path;
    std::string map_data_path;

    unsigned char* map_data;
    
    Map_info map_info;
};

#endif